package com.sky.controller.user;

import com.sky.dto.OrdersSubmitDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderSubmitVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: ggm
 * @data 2024年12月17日 18:09
 */
@Slf4j
@RestController("userOrderController")
@RequestMapping("/user/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

     /**
      * @Author: ggm
      * @date:  2024/12/17
      * 提交订单
      */
     @PostMapping("/submit")
     public Result<OrderSubmitVO> submitOrder(@RequestBody OrdersSubmitDTO ordersSubmitDTO){
         log.info("提交订单{}",ordersSubmitDTO);
         OrderSubmitVO orderSubmitVO = orderService.submitOrders(ordersSubmitDTO);
         return Result.success(orderSubmitVO);


     }
      /**
       * @Author: ggm
       * @date:  2024/12/18
       * 分页查询历史订单
       */
      @GetMapping("/historyOrders")
      public Result<PageResult> page(int page, int pageSize, Integer status) {
          PageResult pageResult = orderService.pageQuery(page, pageSize, status);
          return Result.success(pageResult);
      }


}
